<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
    </head>
    <script>
        function Fun(){
            var x = document.getElementById("name");
            x.value=x.value.toUpperCase();
        }
    </script>
    <body>
        输入你的名字:<input type="text" id="name" onchange="Fun()">
        <p>内容改变时触发函数</p>
    </body>
</html>